//
//  MessageViewController.m
//  WhatsChat
//
//  Created by 檀琛 on 16/3/22.
//  Copyright © 2016年 tanchen. All rights reserved.
//

#import "MessageViewController.h"
#import "MessageCell.h"
#import "DetailViewController.h"
#import "WBPopMenuModel.h"
#import "WBPopMenuSingleton.h"
#import "RootTableView.h"

@interface MessageView : RootTableView

@end

@implementation MessageView

@end

@interface MessageViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)MessageView *messageView;

@end

@implementation MessageViewController

- (void)loadView{
    self.messageView = [[MessageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.messageView.backgroundColor = [UIColor blackColor];
    self.view = self.messageView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 设置导航栏所有按钮标题和按钮图像的颜色
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    //导航栏颜色
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.2 green:0.72 blue:0.46 alpha:1];
    //设置透明度
    self.navigationController.navigationBar.translucent = YES;
    //导航栏标题
    self.navigationItem.title = @"消息";
    //设置字体
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    //设置代理
    self.messageView.rootTableView.dataSource = self;
    self.messageView.rootTableView.delegate = self;
    //注册cell
    [self.messageView.rootTableView registerClass:[MessageCell class] forCellReuseIdentifier:@"Message"];
}

//tableView的代理方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 80;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Message"];
    if (!cell) {
        cell = [[MessageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Message"];
    }
    cell.aImageView.image = [UIImage imageNamed:@"iconfont-faxian"];
    cell.nameLabel.text = @"檀琛";
    cell.messageLabel.text = @"为了梦想";
    return cell;
}

#pragma mark ---点击进入下一界面---
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    DetailViewController *detailView = [[DetailViewController alloc]init];
    [self.navigationController pushViewController:detailView animated:YES];
}
//视图出现
- (void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = NO;
}
@end
